<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <!-- 头部操作栏 -->
            <div class="layui-form lay-header">
                <div class="toolbar">
                    <div class="layui-form-item lay-query-content">
                        <div class="lay-query-box">
                            <div class="query-lt">
                                <div class="layui-inline">
                                    <label class="layui-form-label w-auto">单据号：</label>
                                    <div class="layui-input-inline mr0">
                                        <input name="receiptsNo" class="layui-input" type="text" placeholder="输入单据号"/>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label w-auto">物料编号：</label>
                                    <div class="layui-input-inline mr0">
                                        <input name="skuCode" class="layui-input" type="text" placeholder="输入物料编号"/>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label w-auto">物料名称：</label>
                                    <div class="layui-input-inline mr0">
                                        <input name="productName" class="layui-input" type="text" placeholder="输入物料名称"/>
                                    </div>
                                </div>
                            </div>
                            <div class="query-rt">
                                <div class="layui-inline">
                                    <button class="layui-btn icon-btn color-green" lay-filter="formSubSearchLog" lay-submit layui-form-keyDownSearch="true">查询</button>
                                    <button class="layui-btn icon-btn color-white" lay-filter="resets" lay-submit>重置</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 表格 -->
            <table class="layui-table" id="erpPurchaseRequisitionsDetailTable" lay-filter="erpPurchaseRequisitionsDetailTable"></table>
        </div>
    </div>
</div>

<!-- 表格操作列 -->
<script type="text/html" id="erpPurchaseRequisitionsDetail-table-bar">
    {{# if(d.status == 2){ }}
    <a class="layui-btn layui-btn layui-btn-xs" lay-event="enquiry">询价单</a>
    {{# } }}
</script>


<script type="text/html" id="erpPurchaseRequisitionsDetailEnquiry-table-bar">
    {{# if(d.isOffer == 1){ }}
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="offerRecord">报价记录</a>
    {{# } }}
    {{# if(d.isSelect == 0){ }}
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="select">确认</a>
    <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="select">驳回</a>
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    {{# }else if(d.isGenerateOrder == 0){ }}
    <a class="layui-btn layui-btn layui-btn-xs" lay-event="generate">生成采购订单</a>
    {{# } }}
</script>

<script type="text/html" id="erpPurchaseRequisitionsDetail-enquiry-list">
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-form toolbar">
                <button id="enquiry-btn-add" class="layui-btn icon-btn"><i class="layui-icon">&#xe654;</i>添加</button>
            </div>
            <table class="layui-table" id="enquiry-table" lay-filter="enquiry-table"></table>
        </div>
    </div>
</script>

<script type="text/html" id="offerRecord-list">
    <div class="layui-card">
        <div class="layui-card-body">
            <table class="layui-table" id="offerRecord-table" lay-filter="offerRecord-table"></table>
        </div>
    </div>
</script>

<!-- js部分 -->
<script>
    layui.use(['layer', 'form', 'table', 'admin','laytpl','laydate','util'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var config = layui.config;
        var admin = layui.admin;
        var upload = layui.upload;
        var laytpl = layui.laytpl;
        var laydate = layui.laydate;
        var util = layui.util;

        // 渲染表格
        var insTb = table.render({
            elem: '#erpPurchaseRequisitionsDetailTable',
            url: config.base + 'enterprise/purchase/admin/purchaseRequisitionsDetail/list',
            where: {
                order: "desc"
            },
            page: true,
            cellMinWidth: 100,
            cols: [[
                {type: 'numbers'},
                {field: 'receiptsNo', align: 'center', title: '单据号',width:200},
                 {field: 'skuCode', align: 'center', title: '物料编号'},
                {field: 'productName', align: 'center', title: '物料名称'},
                {field: 'specifications', align: 'center', title: '规格型号'},
                {field: 'quantity', align: 'center', title: '请购数量'},
                {field: 'unitName', align: 'center', title: '计量单位'},
                {field: 'rate', align: 'center', title: '税率(%)'},
                {field: 'enquiryStatusDesc',align: 'center', title: '询价状态'},
                {field: 'createTime', sort: true, title: '创建时间', width: 170},
            ]]
        });

        //监听排序
        table.on('sort(erpPurchaseRequisitionsDetailTable)', function(obj){
            table.reload('erpPurchaseRequisitionsDetailTable', {
                initSort: obj
                ,where: {
                    sort: obj.field
                    ,order: obj.type
                }
            });
        });

        // 搜索
        form.on('submit(formSubSearchLog)', function (data) {
            insTb.reload({where: data.field,page: {curr: 1}},'data');
        });

        // 重置搜索
        form.on('submit(resets)', function (data) {
            insTb.reload({where: admin.resetSearch(data.field), page: {curr: 1}}, 'data');
        });

        // 导出excel
        $('#erpPurchaseRequisitionsDetailBtnExport').click(function () {
            var checkRows = table.checkStatus('erpPurchaseRequisitionsDetailTable');
            if (checkRows.data.length == 0) {
                layer.msg('请选择要导出的数据', {icon: 2});
            } else {
                table.exportFile(insTb.config.id, checkRows.data, 'xls');
            }
        });

    });
</script>